How to Programmatically Set the Min and Max Value for a Slider Control

Description

The minimum and maximum value for a two-value Slider Control can be set programmatically at run-time.

Discussion

The Slider Control provides an interface for viewing and editing a single value or range of values in a UX Component. The minimum and maximum value for a Slider Control can be dynamically modified at run-time. This is done by changing the min and max property for the Slider Control's object.

To edit the min and max value of a Slider Control, you must get the Slider object from the UX Component. This is done by calling the {dialog.object}.getControl() method.

Once you have the Slider object, you can set the Slider's min and max value. After setting the min and max value, you must call the Slider object's refresh() method to update the display of the Slider Control in the UX Component.

The example code below sets the minimum value to 10 and the maximum value to 20 for a numeric Slider Control 'S1' in a UX Component:

var sliderObj = {dialog.object}.getControl('S1');

sliderObj.min = 10;
sliderObj.max = 20;

// refresh the Slider control:
sliderObj.refresh();

// Refreshes the Slider message:
var value = slider.value;
{dialog.object}.setValue('S1',value,false);

Download example component that demonstrates the example above.

See Also